package cn.com.apple.pojo;

import cn.com.apple.handle.GenericListTypeHandler;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@TableName("orders")
@AllArgsConstructor
@NoArgsConstructor
public class Order {

    @TableId(type = IdType.ASSIGN_ID)
    private Long order_id;

    private Long user_id;

    @TableField(value = "product_pairs", typeHandler = GenericListTypeHandler.class)
    private List<ProductBuyPair> product_pairs = new ArrayList<>();

    private float total_amount;

    private String order_status;

    private LocalDateTime create_datetime;

    private LocalDateTime update_datetime;

    private String shopping_address;

    public static boolean isValidStatus(String status) {
        return "已取消".equals(status) || "待发货".equals(status) ||
                "发货中".equals(status) || "已发货".equals(status) ||
                "已完成".equals(status);
    }
}